<#include "include/_meta.html">
<!--/meta 作为公共模版分离出去-->

<title>字典信息列表</title>
<meta name="keywords" content="汽车租赁">
<meta name="description" content="汽车租赁">
</head>
<body>
	<div class="page-container">
	<div class="text-c"> 字典名称：
		<input type="text" class="input-text" style="width:250px" placeholder="字典名称" id="name" name="name">
		
		<button type="submit" class="btn btn-success" id="searchSysDicts" name=""><i class="Hui-iconfont">&#xe665;</i> 搜字典</button>
	</div>
		<div class="cl pd-5 bg-1 bk-gray mt-20"> 
			<span class="l">
				<a href="javascript:;" onclick="sysdict_add('添加字典信息','/sysdictadd','800','500')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加字典信息</a>
			</span> 
			<span class="r">共有数据：<strong id="pageTotal">54</strong> 条</span>
		 </div>
		 
		<table id="sysDictListTable" class="table table-border table-bordered table-bg table-hover">
			<thead>
				<tr class="text-c">
					<th>字典编号</th>
					<th>父类编号</th>
					<th>字典名称</th>
					<th>字典代码</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
					
			</tbody>
		</table>
	</div>
<!--_footer 作为公共模版分离出去--> 
<#include "include/_footer.html">
<script type="text/javascript">
	$(function(){
		initTable();
	});
	
	var initTable = function(){
		$("#sysDictListTable").dataTable({
			"processing": false,
      	"serverSide": true,
      	"bSort": false,
      	"bFilter":false,
      	"bLengthChange":false,
      	"iDisplayLength":10,
      	"bRetrieve":true,
      	"ajax": {
            "url": "/sysdicts", 
           	"data":function(d){
		        d.name = $('#name').val();
		    },
            "type": "post"
        },
        "columns": [
            { "data": "id" },
            { "data": "fId" },
            { "data": "name" },
			{ "data": "code" },
            { "data": "" }
      	],
      	"columnDefs": [
	        {
		          "targets": [4],
		          "data": "id",
		          "render": function(data, type, full) {		          	
		          	var action_look = "<a style='text-decoration:none' onClick=\"sysdict_look('字典详细信息','/sysdictget?id="+full.id+"','2','800','500')\" href=\"javascript:;\" title=\"详情\"><i class=\"Hui-iconfont\">&#xe665;</i></a>";
		          	if(full.fId != '0'){
		          		var action_edit    = "<a title=\"编辑\" href=\"javascript:;\" onclick=\"sysdict_edit('字典信息编辑','/sysdictedit?id="+full.id+"','2','800','500')\" class=\"ml-5\" style=\"text-decoration:none\"><i class=\"Hui-iconfont\">&#xe6df;</i></a>";
		          		if(full.fId != '1'){
			          		var action_edit    = "<a title=\"编辑\" href=\"javascript:;\" onclick=\"sysdict_edit('字典信息编辑','/sysdictedit?id="+full.id+"','2','800','500')\" class=\"ml-5\" style=\"text-decoration:none\"><i class=\"Hui-iconfont\">&#xe6df;</i></a>";
			          		var action_del     = "<a title=\"删除\" href=\"javascript:;\" onclick=\"sysdict_del(this,'"+full.id+"')\" class=\"ml-5\" style=\"text-decoration:none\"><i class=\"Hui-iconfont\">&#xe6e2;</i></a>";
			          		return action_look+" "+action_edit+" "+action_del;
		          		}
		          		return action_look+" "+action_edit;
		          	}
		          	
		          	
		           	return action_look;
		          }
	        }	        
      	],
      	"fnRowCallback" : function(nRow, aData, iDisplayIndex) { 
      					nRow.className="text-c";         
                    //    $('td:eq(0)', nRow).html(iDisplayIndex+1);  
                                   
                        return nRow;  
         },
	    "fnDrawCallback": function(oSettings) {
		      //获取后台方式 直接可以拿到json 之后进行处理
		      var json=jQuery.parseJSON(oSettings.jqXHR.responseText);  
		      $("#pageTotal").html(json.recordsTotal);
	    }
		});
	}
	
	
	//添加字典信息
	function sysdict_add(title,url,w,h){
		layer_show(title,url,w,h);
	}
	
	/*字典信息-查看*/
	function sysdict_look(title,url,id,w,h){
		layer_show(title,url,w,h);
	}
	
	/*字典信息-编辑*/
	function sysdict_edit(title,url,id,w,h){
		layer_show(title,url,w,h);
	}

	//根据条件进行查询
	$("#searchSysDicts").click(function(){
		$("#sysDictListTable").dataTable().fnClearTable();
       		 initTable();
	});
	
	/*字典信息-删除*/
	function sysdict_del(obj,id){
		layer.confirm('确认要删除吗？',function(index){
			//此处请求后台程序，下方是成功后的前台处理……
			
			
			$.ajax({
			   type: "POST",
			   url: "/deletesysdict",
			   data: "id="+id,
			   success: function(msg){
			       	$("#gradeListTable").dataTable().fnClearTable();
	        		initTable();
			   }
			});
			
			
			$(obj).parents("tr").remove();
		layer.msg('已删除!',{icon:1,time:1000});
		});
	}
</script>
</body>
</html>